# @Filename:    Sample1-add
# @Author:      王佳伟
# @Time:        2025-02-28 9:25
# @Describe:    列表去重
import unittest


def average(lst):
    if not lst:
        raise ZeroDivisionError("Cannot calculate average of an empty list.")
    return sum(lst) / len(lst)


class TestAverage(unittest.TestCase):
    def test_average(self):
        self.assertEqual(average([1, 2, 3, 4, 5]), 3)
        self.assertEqual(average([10, 20, 30]), 20)
        with self.assertRaises(ZeroDivisionError):
            average([])


if __name__ == '__main__':
    unittest.main()
